<template>
  <div>
    <!-- 思维链内容显示 (蓝色圆圈) -->
    <div v-if="reasoningContent" class="reasoning-content mb-3">
      <div class="reasoning-header">
        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-blue-400 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" />
        </svg>
        <span>深度思考</span>
      </div>
      <div class="reasoning-text">
        <template v-for="(paragraph, idx) in formattedReasoningContent">
          <p v-if="paragraph" :key="`reasoning-${idx}`" :class="{ 'mt-2': idx > 0 }">{{ paragraph }}</p>
          <br v-else :key="`reasoning-br-${idx}`">
        </template>
      </div>
    </div>
    
    <!-- 正文内容 -->
    <div class="message-content">
      <template v-for="(paragraph, idx) in formattedContent">
        <p v-if="paragraph" :key="idx" :class="{ 'mt-2': idx > 0 }">{{ paragraph }}</p>
        <br v-else :key="`br-${idx}`">
      </template>
    </div>
  </div>
</template>

<script setup>
import { defineProps, computed } from 'vue';

const props = defineProps({
  content: {
    type: String,
    required: true
  },
  reasoningContent: {
    type: String,
    default: ''
  }
});

// 处理消息内容的换行
const formattedContent = computed(() => {
  return props.content.split('\n');
});

// 处理思维链内容的换行
const formattedReasoningContent = computed(() => {
  return props.reasoningContent ? props.reasoningContent.split('\n') : [];
});
</script>

<style scoped>
.message-content {
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.reasoning-content {
  border: 1px solid #3b82f6;
  border-radius: 0.5rem;
  padding: 0.75rem;
  background-color: rgba(59, 130, 246, 0.1);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.reasoning-header {
  display: flex;
  align-items: center;
  font-weight: 500;
  color: #3b82f6;
  margin-bottom: 0.5rem;
}

.reasoning-text {
  color: #4b5563;
}
</style> 